import 'package:app/utils/LogUtil.dart';
import 'package:dio/dio.dart';
Future getHttpPost(String url,Map<String,String> map) async{
  try{
    Response response;
    Dio dio=Dio();
    dio.options.contentType="application/x-www-form-urlencoded; charset=UTF-8";
    dio.options.responseType=ResponseType.plain;
    response=await dio.post(url,data: map);
    if(response.statusCode==200){
      print("response.data=======${response.data}");
      return response.data;
    }else{
      throw Exception("请求失败");
    }
  }catch(e){
    print(e);
  }
}

Future getDataPost(String url,Map<String,String> map) async{
  try{
    String cookie="companyCode=bpjs; username=yjb; password=123;BDCloudWater=4AC5E2861DBD69D056D2D70CEC97384E";
    Response response;
    Dio dio=Dio();
    dio.options.connectTimeout = 10000;        // 服务器链接超时，毫秒
    dio.options.receiveTimeout = 3000;        //响应流上前后两次接受到数据的间隔，毫秒
    dio.options.responseType=ResponseType.plain;
    Map<String,dynamic> headers = new Map();
    headers['Cookie'] = cookie;
    headers['Content-Type'] = "application/x-www-form-urlencoded; charset=UTF-8";
    Options options = new Options(
        headers:headers
    );

    response=await dio.post(url,data: map,options: options);

    if(response.statusCode==200){
      LogUtil.d("response.data=======${response.data}");

      return response.data;
    }else{
      throw Exception("请求失败");
    }
  }catch(e){
    print(e);
  }

  Future getDataPost1(String url,Map<String,String> map) async{
    try{
      String cookie="companyCode=bpjs; username=yjb; password=123;BDCloudWater=4AC5E2861DBD69D056D2D70CEC97384E";
      Response response;
      Dio dio=Dio();
      dio.options.connectTimeout = 10000;        // 服务器链接超时，毫秒
      dio.options.receiveTimeout = 3000;        //响应流上前后两次接受到数据的间隔，毫秒
      dio.options.responseType=ResponseType.plain;
      Map<String,dynamic> headers = new Map();
      headers['Cookie'] = cookie;
      headers['Content-Type'] = "application/x-www-form-urlencoded; charset=UTF-8";
      Options options = new Options(
          headers:headers
      );

      response=await dio.post(url,data: map,options: options);

      if(response.statusCode==200){
        LogUtil.d("response.data=======${response.data}");

        return response.data;
      }else{
        throw Exception("请求失败");
      }
    }catch(e){
      print(e);
    }
  }



}